Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bcs]Add Serialized type and serialization methods for handling byte arrays #135

Merged
merged 2 commits into from
Mar 11, 2025

Conversation

WGB5445
Copy link
Contributor

@WGB5445 WGB5445 commented Mar 10, 2025

Description

Support new Serialized type for Script.

Test Plan

examples/script_transaction

Related Links

ts-sdk: aptos-labs/aptos-ts-sdk@5387884

@WGB5445 WGB5445 requested review from gregnazario and a team as code owners March 10, 2025 09:15
Comment on lines +1 to +29
package bcs

// Serialized represents a serialized transaction argument
type Serialized struct {
Value []byte
}

// NewSerialized creates a new Serialized instance
func NewSerialized(value []byte) *Serialized {
return &Serialized{
Value: value,
}
}

// Serialize serializes the Serialized instance
func (s *Serialized) Serialized(serializer *Serializer) {
serializer.WriteBytes(s.Value)
}

// SerializeForEntryFunction serializes the Serialized instance for entry function
func (s *Serialized) SerializedForEntryFunction(serializer *Serializer) {
s.Serialized(serializer)
}

// SerializeForScriptFunction serializes the Serialized instance for script function
func (s *Serialized) SerializedForScriptFunction(serializer *Serializer) {
serializer.Uleb128(uint32(9))
s.Serialized(serializer)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In what situation would this not work as a vector? It should be encoded as bytes right?

or is there something I'm missing

@gregnazario gregnazario merged commit ca456d4 into main Mar 11, 2025
1 check passed
@gregnazario gregnazario deleted the logan/serialized-type branch March 11, 2025 02:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants